package com.nuoyuan.wx.common.constant;

import com.nuoyuan.wx.common.utils.HashUtil;

import java.text.MessageFormat;

/**
 * @Package com.nuoyuan.wx.common.constant
 * @ClassName RedisConstant
 * @Description TODO
 * @Author linus
 * @Date 2020-02-21 21:29
 * @Version 1.0
 **/
public class RedisConstant {
    //wx-phone-smsType
    public static final String WX_AUTHCODE = "wx-authcode-{0}-{1}";
    //wx-login-idNo
    public static final String WX_LOGIN = "wx-login-{0}";
    //collect-userId
    public static final String WX_USER_COLLECT = "collect-{0}";

    public static final long WX_LOGIN_EXPIRE_TIME = 60 * 60 * 1000L;

    public static final long AUTHCODE_EXPIRE_TIME = 120L;

    public static String getWxAuthcodeKey(String phone, String smsType) {
        return HashUtil.getStringMD5(MessageFormat.format(WX_AUTHCODE, phone, smsType));
    }

    public static String getWxUserCollectKey(Long userId) {
        return HashUtil.getStringMD5(MessageFormat.format(WX_USER_COLLECT, userId));
    }
}
